package com.mrogrape.notepad.ui.filechooser;

import java.io.File;

import javax.swing.filechooser.FileFilter;

import com.mrogrape.notepad.ui.editor.ContentType;

/**
 * 过滤指定内容类型的文件过滤器。
 * 
 * @author Ice Spring
 *
 */
public class ContentTypeFileFilter extends FileFilter{

	private ContentType contentType;
	
	public ContentTypeFileFilter(ContentType contentType) {
		
		this.contentType = contentType;
	}

	@Override
	public boolean accept(File f) {
		
		if(f.isDirectory()){return true;}
		
		return this.contentType.isFileSupportedFor(f);
	}

	@Override
	public String getDescription() {
		
		return this.contentType.getShortDescription();
	}

	/**
	 * @return the contentType
	 */
	public ContentType getContentType() {
		return this.contentType;
	}
}
